var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function n() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((n.prototype = i.prototype), new n()));
      };
    })(),
  DPItemDetailPageView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        e.btn_item_buy.on(Laya.Event.CLICK, e, e.onDidClickPageClick),
        WebSocketService.addListener({
          caller: e,
          code: 1317,
          method: e.onLoadDeleteThingData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1312,
          method: e.onLoadThingDataFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 6192,
          method: e.onLoadThingHuiShiDataFn,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 1297,
          method: e.onLoadThingDataFn,
        }),
        WebSocketService.addListener(
          { caller: e, code: 1302, method: e.onLoadEquimentDataFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: e, code: 1267, method: e.onLoadThingDataFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: e, code: 2083, method: e.onLoadThingDataFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: e, code: 2099, method: e.onLoadThingDataFn },
          !0
        ),
        WebSocketService.addListener(
          { caller: e, code: 2078, method: e.onLoadJiShouWupinFn },
          !0
        ),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showItemDetailPageView = function (t, i) {
        return (
          null == this.detailPageV &&
            ((this.detailPageV = new e()), (this.detailPageV.zOrder = 1e3)),
          this.detailPageV.popup(!0),
          (this.detailPageV.className = i),
          (this.detailPageV.thingObj = t),
          (this.detailPageV.label_page_content.text = ""),
          (this.detailPageV.image_itemDetail_icon.skin = ""),
          "AXEquipmentView" == i
            ? this.detailPageV.initEquipmentUI()
            : "AXFlyMyMarketView" == i
            ? this.detailPageV.initFlyMyMarketUI()
            : "AXShoppingItemView" == i
            ? this.detailPageV.initShoppingItemUI()
            : "DPPawnShopView" == i && this.detailPageV.initPawnShopUI(),
          this.detailPageV
        );
      }),
      (e.prototype.initPawnShopUI = function () {
        (this.label_page_title.text = this.thingObj.name),
          (this.label_page_subTitle.text =
            this.thingObj.count + " 个   " + this.thingObj.money + " 金"),
          5 == this.thingObj.thing_type
            ? WebSocketService.send({
                c: 2099,
                d: { id: this.thingObj.thing_id },
              })
            : WebSocketService.send({
                c: 2083,
                d: { id: this.thingObj.thing_id },
              }),
          "jishou" == this.thingObj.type
            ? (this.btn_item_buy.label = "删除")
            : (this.btn_item_buy.label = "购买");
      }),
      (e.prototype.initShoppingItemUI = function () {
        (this.label_page_title.text = this.thingObj.name),
          (this.label_page_subTitle.text =
            this.thingObj.count + " 个   " + this.thingObj.money + " 银"),
          WebSocketService.send({ c: 1267, d: { id: this.thingObj.thing_id } }),
          (this.btn_item_buy.label = "购买");
      }),
      (e.prototype.initEquipmentUI = function () {
        (this.label_page_title.text = this.thingObj.name),
          (this.label_page_subTitle.text =
            this.thingObj.count + " 个    " + this.thingObj.money + " 银"),
          WebSocketService.send({ c: 1297, d: { id: this.thingObj.thing_id } }),
          (this.btn_item_buy.label = "购买");
      }),
      (e.prototype.initFlyMyMarketUI = function () {
        (this.label_page_title.text = this.thingObj.name),
          (this.label_page_subTitle.text =
            this.thingObj.count + " 个    " + this.thingObj.money + " 银"),
          "my" == this.thingObj.type
            ? (this.btn_item_buy.label = "删除")
            : (this.btn_item_buy.label = "购买"),
          "5" == this.thingObj.thing_type
            ? WebSocketService.send({
                c: 2099,
                d: { id: this.thingObj.thing_id },
              })
            : "2" == this.thingObj.thing_type
            ? WebSocketService.send({
                c: 2083,
                d: { id: this.thingObj.thing_id },
              })
            : "6" == this.thingObj.thing_type
            ? WebSocketService.send({
                c: 6192,
                d: { id: this.thingObj.thing_id },
              })
            : WebSocketService.send({
                c: 1312,
                d: { gid: this.thingObj.thing_id },
              });
      }),
      (e.prototype.onLoadThingDataFn = function (t) {
        if (0 == t.code) {
          for (var e = "", i = "", n = "", a = 0; a < t.data.length; a++) {
            var o = t.data[a],
              h = o.k,
              s = o.v;
            "图片：" != h && "图片:" != h
              ? "roleName:" != h
                ? "roleId:" != h
                  ? (e = e + h + " " + s + "\n")
                  : (n = s)
                : (i = s)
              : (this.image_itemDetail_icon.skin = "arming/" + s + ".png");
          }
          "AXShoppingItemView" != this.className &&
            (this.label_page_title.text = i + "(" + n + ")"),
            (this.label_page_content.text = e),
            t.data.length > 4
              ? ((this.height = 420), (this.label_page_content.height = 260))
              : ((this.height = 320), (this.label_page_content.height = 160)),
            (this.label_page_subTitle.bottom = 70);
        } else ToastView.toastView(t.msg);
      }),
      (e.prototype.onLoadThingHuiShiDataFn = function (t) {
        if (0 == t.code) {
          var e = "",
            i = t.data;
          (e =
            "效果：" +
            i.descr +
            "\n经验" +
            i.e +
            "/" +
            i.eUp +
            "\n等级：" +
            i.lvl +
            "\n升级耗银：" +
            i.silver),
            (this.label_page_content.text = e);
        } else ToastView.toastView(t.msg);
      }),
      (e.prototype.onDidClickPageClick = function (t) {
        if ("删除" == t.target.label)
          "DPPawnShopView" == this.className
            ? WebSocketService.send({ c: 2076, d: { act: 3, gold: 0 } })
            : "AXFlyMyMarketView" == this.className &&
              WebSocketService.send({ c: 1317, d: { pos: this.thingObj.pos } }),
            this.close();
        else if ("AXEquipmentView" == this.className)
          WebSocketService.send({
            c: 1302,
            d: { id: this.thingObj.thing_id, type: 0 },
          });
        else if ("AXFlyMyMarketView" == this.className) {
          var e = {
            chargeID: this.thingObj.stallId,
            thingID: this.thingObj.thing_id,
            chargeSum: this.thingObj.count,
            chargePos: this.thingObj.pos,
            chargeTitle: this.thingObj.name,
            chargeMoney: this.thingObj.money,
          };
          MTPitchChargeView.shoppingOpen(e);
        } else if ("AXShoppingItemView" == this.className) {
          var i = {
            id: this.thingObj.thing_id,
            name: this.thingObj.name,
            price: this.thingObj.money,
          };
          AXGiveGiftView.show(i);
        } else
          "DPPawnShopView" == this.className &&
            NormalDialog.showNormalDialog(
              "您确定花费 " +
                this.thingObj.money +
                " 金购买 \n" +
                this.thingObj.name,
              this,
              this.onSureBuyMethod
            );
      }),
      (e.prototype.onSureBuyMethod = function () {
        WebSocketService.send({ c: 2097, d: { pawnId: this.thingObj.pawnId } });
      }),
      (e.prototype.onLoadDeleteThingData = function (t) {
        0 == t.code
          ? ToastView.toastView("删除成功")
          : ToastView.toastView(t.msg);
      }),
      (e.prototype.onLoadJiShouWupinFn = function (t) {
        0 == t.code
          ? WebSocketService.send({ c: 2075, d: null })
          : ToastView.toastView(t.msg);
      }),
      (e.prototype.onLoadEquimentDataFn = function (t) {
        0 == t.code && WebSocketService.send({ c: 1451, d: { pageNum: 0 } }),
          ToastView.toastView(t.msg),
          this.close();
      }),
      e
    );
  })(ui.MarketController.DPItemDetailPageViewUI);
